/*******************************************************************************
 * @project: Java_Reflect
 * @package: com.burns.java.reflect
 * @file: GetParentClassAndInterface.java
 * @author: Administrator
 * @created: 2017年5月13日
 * @purpose:
 * 
 * @version: 1.0
 * 
 * Revision History at the end of file.
 * 
 * Copyright 2017 AcconSys All rights reserved.
 ******************************************************************************/

package com.burns.java.reflect;

import java.io.Serializable;

/**
 * 获取一个对象的父类与实现的接口
 * 
 * @author Administrator
 *
 */
public class GetParentClassAndInterface implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 9206985772022101438L;

	public static void main(String[] args) throws ClassNotFoundException {
		Class<?> clazz = Class.forName("com.burns.java.reflect.GetParentClassAndInterface");
		// 取得父类
		Class<?> parentClass = clazz.getSuperclass();
		System.out.println("clazz的父类为：" + parentClass.getName());

		// 获取所有接口
		Class<?> intefaces[] = clazz.getInterfaces();
		System.out.println("clazz实现的接口有：");

		for (int i = 0; i < intefaces.length; i++) {
			System.out.println((i + 1) + ":" + intefaces[i].getName());
		}

		/**
		 * 结果输出
		 * 
		 * clazz的父类为：java.lang.Object 
		 * clazz实现的接口有： 1:java.io.Serializable
		 * 
		 */
	}
}

/*******************************************************************************
 * <B>Revision History</B><BR>
 * [type 'revision' and press Alt + / to insert revision block]<BR>
 * 
 * 
 * 
 * Copyright 2017 AcconSys All rights reserved.
 ******************************************************************************/